<!DOCTYPE html>
<html lang="en">
	<head>
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
		<meta charset="utf-8" />
		<title>role Admin</title>

		<meta name="description" content="" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />

		<!-- bootstrap & fontawesome -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/bootstrap.css" />
		<link rel="stylesheet" href="#(CPATH)/assets/css/font-awesome.css" />

		<!-- page specific plugin styles -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/bootstrap-table.css">
		<link rel="stylesheet" href="#(CPATH)/assets/css/basejace.css">

		<!-- text fonts -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/ace-fonts.css" />

		<!-- ace styles -->
		<link rel="stylesheet" href="#(CPATH)/assets/css/ace.css" class="ace-main-stylesheet" id="main-ace-style" />

		<!--[if lte IE 9]>
			<link rel="stylesheet" href="#(CPATH)/assets/css/ace-part2.css" class="ace-main-stylesheet" />
		<![endif]-->

		<!--[if lte IE 9]>
		  <link rel="stylesheet" href="#(CPATH)/assets/css/ace-ie.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- ace settings handler -->
		<script src="#(CPATH)/assets/js/ace-extra.js"></script>

		<!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

		<!--[if lte IE 8]>
		<script src="#(CPATH)/assets/js/html5shiv.js"></script>
		<script src="#(CPATH)/assets/js/respond.js"></script>
		<![endif]-->
	</head>

	<body class="no-skin">
		<div class="main-container" id="main-container">
			<script type="text/javascript">
				try{ace.settings.check('main-container' , 'fixed')}catch(e){}
			</script>
			<div class="main-content">
			<!-- 提示信息条 -->
			#if(message != null)
			<div class="row">
				<div class="col-xs-12">
					<div class="alert alert-info">
						<button type="button" class="close" data-dismiss="alert">
							<i class="ace-icon fa fa-times"></i>
						</button>
						#(message)
					</div>
				</div>
			</div><!-- ./提示信息条 -->
			#end
			<!-- 这里是查询条件 -->
			<div class="row">
				<div class="col-xs-12">
					<div class="widget-box transparent">
						<div class="widget-body form-field">
								<!-- 一行查询条件 -->
								<div class="row">
									<div class="col-xs-12 col-sm-4">
										<label class="p35">角色名称</label>
										<input type="text" id="rolename" name="rolename" class="p55"/>
									</div>
								</div>
						</div>
						
						<div class="widget-header text-right">
							<div class="widget-toolbar">
							<button id="queryBtn" class="btn btn-sm btn-info" ><i class="ace-icon glyphicon glyphicon-search bigger-120"></i>查询</button>
							<button class="btn btn-sm"><i class="icon-search align-top"></i>重置</button>
							</div>
						</div>
						
					</div>
				</div>
			</div>

<!-- 这里是表格及工具条 -->
			<div class="row">
				<div class="col-xs-12">
					<div class="widget-box transparent">
						
						<div class="widget-body">
							<div class="widget-main no-padding-top">
								<div id="toolbar">
									<button class="btn btn-sm btn-white btn-info" onclick="doAdd()"><i class="ace-icon fa fa-plus"></i>新增</button>
									<button class="btn btn-sm btn-white " onclick="doEdit()"><i class="ace-icon fa fa-edit"></i>修改</button>
									<button class="btn btn-sm btn-white btn-danger" onclick="doDelete('roleid')"><i class="ace-icon fa fa-trash-o"></i>删除</button>
									<button class="btn btn-sm btn-white pull-right" onclick="card()"><i class="ace-icon glyphicon glyphicon-th-large bigger-120"></i>123</button>
								</div>
								<table id="datatable">
									<thead>
										<tr>
										<th data-field="checked" data-checkbox="true"></th>
										<th data-field="roleid" data-visible="false">ID</th>
										<th data-field="rolename">角色名称</th>
										<th data-field="role_note">说明</th>
										<th data-formatter="operator">操作</th>
										</tr>
									</thead>
								</table>
							</div>
						</div>
					</div>
				</div>
			
			</div>


			</div>
		</div>


<!-- 这里是赋权模态框 -->
<div class="modal fade" id="authority">  
   <div class="modal-dialog" >  
       <div class="modal-content">  
           <div class="modal-header">  
           		<button type="button" class="close" data-dismiss="modal"> × </button>
               <!-- <button type="button" class="close" onclick="window.history.go(-1);">×</button>   -->
               <h4 class="modal-title" id="NoPermissionModalLabel">给角色赋权</h4>  
           </div>  
           <div class="modal-body">  
                <iframe id="authoritytree" width="100%" height="100%" frameborder="0"></iframe>  
            </div>  
            <!-- <div class="modal-footer">  
				<button type="button" class="btn btn-default " data-dismiss="modal">    关  闭    </button>
            </div>   -->
        </div>  
    </div>  
</div>
<!-- ./这里是赋权模态框 -->

		<!-- basic scripts -->

		<!--[if !IE]> -->
		<script type="text/javascript">
			window.jQuery || document.write("<script src='#(CPATH)/assets/js/jquery.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='#(CPATH)/assets/js/jquery1x.js'>"+"<"+"/script>");
</script>
<![endif]-->
		<script type="text/javascript">
			if('ontouchstart' in document.documentElement) document.write("<script src='#(CPATH)/assets/js/jquery.mobile.custom.js'>"+"<"+"/script>");
		</script>
		<script src="#(CPATH)/assets/js/bootstrap.js"></script>

		<!-- page specific plugin scripts -->
		<script src="#(CPATH)/assets/js/bootstrap-table/bootstrap-table.js"></script>
		<script src="#(CPATH)/assets/js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
		<script src="#(CPATH)/assets/js/bootbox.js"></script>
		<script src="#(CPATH)/assets/js/basejace-page.js"></script>
		
		<!-- ace scripts -->
		<script src="#(CPATH)/assets/js/ace/elements.scroller.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.colorpicker.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.fileinput.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.typeahead.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.wysiwyg.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.spinner.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.treeview.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.wizard.js"></script>
		<script src="#(CPATH)/assets/js/ace/elements.aside.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.ajax-content.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.touch-drag.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.sidebar.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.sidebar-scroll-1.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.submenu-hover.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.widget-box.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.settings.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.settings-rtl.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.settings-skin.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.widget-on-reload.js"></script>
		<script src="#(CPATH)/assets/js/ace/ace.searchbox-autocomplete.js"></script>

		<!-- inline scripts related to this page -->
		<script type="text/javascript">
			cmdAdd = "#(CPATH)/system/role/add";
			cmdView = "#(CPATH)/system/role/view";
			cmdEdit = "#(CPATH)/system/role/edit";
			cmdDelete = "#(CPATH)/system/role/delete";
			cmdList = "#(CPATH)/system/role/list";
			
			
			//绑定到bootstraptalbe插件中的 queryParams 的属性，增加查询方法中的参数
			function btableQueryParam(params) {
				params['rolename'] = $("#rolename").val();
				//alert(JSON.stringify(params));
				return params;
			}
			
			function btableOnDblClickRow(row, $element, field) {
				//row：点击行的数据对象
				//$element：tr 元素，
				//field：点击列的 field 名称。 
				window.location = cmdView + "?PK=" + row.roleid;
			}
			/* 
			
			$(function(){
				//解决改变搜索条件，重新点击查询按钮 开始查询
				$("#queryBtn").click(function () {
					$("#datatable").bootstrapTable('destroy');
					TableObj.oTableInit();
				});
				//解决改变搜索条件，重新点击查询按钮 开始查询
				var TableObj = {
					oTableInit: function(){
						$("#datatable").bootstrapTable({
							pagination: true,			//设置为 true 会在表格底部显示分页条
							sidePagination: "server",	//设置为服务端分页，默认为client
							url:"#(CPATH)/system/role/list",	//请求数据地址
							//dataType: "json",
							pageSize: 10,				//默认每页展示条数
							striped: true,				//表格间色显示
							cache: false,				//是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性
							toolbar: "#toolbar",
							toolbarAlign: "center",
							buttonsClass: "sm",
							//showToggle: true	,		//是否显示 切换视图（table/card）按钮 
							queryParams: function(params) {
								//设置查询条件到服务器端
								//alert(JSON.stringify(params));
								params['rolename'] = $("#rolename").val();
								//alert(JSON.stringify(params));
								return params;
							},
							onDblClickRow: function(row, $element, field) {
								//row：点击行的数据，
								//$element：tr 元素，
								//field：点击列的 field 名称。 
								window.location = cmdView + "?PK=" + row.roleid;
							}
						});
					}
				};
				
				TableObj.oTableInit();
				
			});		 */
			
			function operator(value, row, index) {
				//value是当前列的值
				//row 是当前行的数据对象 {colname1: colvalue1, colname2: colvalue2...}，可以使用JSON.stringify(row)来打印出来
				//index 是页面上的表格的当前第几行,从0开始
				var str = "<button class='btn btn-xs' style='margin-bottom:3px' onclick='openModel(\"" +row.roleid + "\")'>赋权</button> <button class='btn btn-xs' style='margin-bottom:3px' >删除</button>";
				return  str;
			}
			
			function openModel(roleid) {
				var frameSrc = "#(CPATH)/system/authority/show?roleid="+roleid;  
				$("#authoritytree").attr("src", frameSrc);  
				$('#authority').modal({ show: true, backdrop: 'static' }); 
				parent.$('html,body').animate({
		               scrollTop: 0
		           }, 'slow');
			}
			/*
			function doDelete() {
				var selectObj = $("#datatable").bootstrapTable('getAllSelections');
				var pks = "";
				for (var i=0; i< selectObj.length; i++){
					pks += selectObj[i].roleid + ","
				}
				
				if (pks == "") {
					bootbox.alert({
						buttons: {  
			               ok: {  
			                    label: 'OK',  
			                    className: 'btn-info'  
			                }  
			            },  
			            message: '请先选择要删除的记录',  
			            callback: function() {  
			                //alert('关闭了alert');  
			            },  
			            title: "提示", 
					});
					return;
				}
				
				bootbox.confirm("你确定要删除 " + selectObj.length + "条记录吗？", function (result) {  
	                if(result) {  
	                    window.location = cmdDelete + "?PK=" + pks;
	                } else {  
	                    
	                }  
	            });  
				
				//alert(selectObj.length);
				//alert('getSelections: ' + JSON.stringify($("#datatable").bootstrapTable('getAllSelections')));
			}*/
			
			function doAdd() {
				location.href = cmdAdd;
			}
			
			function doEdit() {
				var selectObj = $("#datatable").bootstrapTable('getAllSelections');
				var pks = "";
				for (var i=0; i< selectObj.length; i++){
					pks += selectObj[i].roleid + ","
				}
				if (selectObj.length != 1) {
					bootbox.alert({
						buttons: {  
			               ok: {  
			                    label: 'OK',  
			                    className: 'btn-info'  
			                }  
			            },  
			            message: '请选中一条记录进行编辑！',  
			            callback: function() {  
			                //alert('关闭了alert');  
			            },  
			            title: "提示", 
					});
					return;
				}
				location.href = cmdEdit + "?PK=" + pks;
			}
			
			function card() {
				
			}
			
			function query() {
				$("#datatable").bootstrapTable({pageNumber: 1});
				$("#datatable").bootstrapTable("refresh");
			}
			
			
			init_list();
			
			
		</script>
	</body>
</html>
